<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" lang="fr">

<wicket:head>
	<title>Sélectionner un service</title>
</wicket:head>

<body>
<wicket:panel>
	<div class="container">
	  <h1>Recherche de service</h1>
	  <hr>
<!--	  <form wicket:id="selectForm" action="">-->
		<div class="span-6" id="treeview-wrapper">
		  <span id="treeview" wicket:id="treeview"></span>
		</div>
<!--	  </form>-->
	</div>
	<wicket:link>
		<script type="text/javascript">
			var first = false;
			
			$(function () {
				$("#treeview").jstree({ 
					plugins : [ "themes", "json_data" ],
					themes : {
						theme: "classic"
					},
					json_data: {
						progressive_render: true,
						data: [
						         {
	                    			data : "Ministère",
	                    			attr : {
	                    				id : "0"
	                    			},
	                    			state : "closed"
	                			}
						],
						ajax : {
							async: true,
							url: "browse?showmenu=false",
							datatype: "json",
							data: function (n) {
								return { id : n.attr ? n.attr("id") : 0 };
							}
						}
					},
					core : {
						html_titles : true,
						strings : {
							loading : "Chargement en cours..."
						}
					}
				});
	
				$("#treeview").bind("reselect.jstree", function(event, data) {
			        first = true;
				});
	
				$("#treeview").bind("select_node.jstree", function(event, data) {
					alert('select_node.jstree');
					if (!first) {
				    	return;
				    } 
					var href = data.rslt.obj.attr("href");
			        var path = window.location.href;
			        alert("id: " + data.rslt.obj.attr("id"));
			        alert("path: " + path);
			        id = data.rslt.obj.attr("id");
			        document.location.href = href + "&id=" + id;
			        return true;
			    });
	
			});
		</script>
	</wicket:link>
</wicket:panel>

</body>
</html>
  